//
//  RCRecommendFoodCell.m
//  RocketProject
//
//  Created by chen jiedan on 13-6-25.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCRecommendFoodCell.h"
#import "CommonDefines.h"
#import "UIColor-Expanded.h"
#import "UIImageView+WebCache.h"

#define kBGImageFile             @"image_discount_cell_bg.png"
#define kLineImageFile           @"image_line_type3.png"
#define kDefaultImageFile        @"image_default.png"

@implementation RCRecommendFoodCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self setUpView];
    }
    return self;
}

- (void) dealloc
{
    [_imageArea release];
    [_foodNameLabel release];
    [_restaurantLabel release];
    [_descLabel release];
    [super dealloc];
}
- (void) setUpView
{
//    self.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:kBGImageFile ofType:nil]]];
    _imageArea = [[UIImageView alloc] initWithFrame:CGRectMake(14, 17, 105, 75)];
    [self.contentView addSubview:_imageArea];

    
    _foodNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 20, 180, 20)];
    _foodNameLabel.font = [UIFont fontWithName:kFontNameHeiti size:16];
    _foodNameLabel.textColor = [UIColor colorWithHex:0xff505050];
    _foodNameLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_foodNameLabel];
//    [_foodNameLabel release];
    
    
    _restaurantLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 42, 180, 20)];
    _restaurantLabel.font = [UIFont fontWithName:kFontNameHeiti size:14];
    _restaurantLabel.textColor = [UIColor colorWithHex:0xff505050];
    _restaurantLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_restaurantLabel];
//    [_restaurantLabel release];
    
    
    _descLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 65, 180, 28)];
    _descLabel.font = [UIFont fontWithName:kFontNameHelvetica size:12];
    _descLabel.numberOfLines = 2;
    _descLabel.textColor = [UIColor colorWithHex:0xff989797];
    _descLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_descLabel];

    UIImageView *_lineImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 108, 320, 1)];
    _lineImageView.backgroundColor = [UIColor clearColor];
    NSString *filePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:kLineImageFile];
    [_lineImageView setImage:[UIImage imageWithContentsOfFile:filePath]];
    [self.contentView addSubview:_lineImageView];
    [_lineImageView release];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void) bindData:(RCRecommendFoodItemDataModel *)dataItem
{
    [_imageArea setImageWithURL:[NSURL URLWithString:dataItem.picUrl] placeholderImage:[UIImage imageNamed:kDefaultImageFile]];
    _foodNameLabel.text = dataItem.foodName;
    _descLabel.text     = dataItem.desc;
    _restaurantLabel.text=dataItem.restaurant;

}

@end
